import { defHttp } from '/@/utils/http/axios';
import { useMessage } from "/@/hooks/web/useMessage";

const { createConfirm } = useMessage();

enum Api {
	list = '/couple-activity/activity/coupleActivityOrder/list',
	save = '/couple-activity/activity/coupleActivityOrder/add',
	edit = '/couple-activity/activity/coupleActivityOrder/edit',
	deleteOne = '/couple-activity/activity/coupleActivityOrder/delete',
	deleteBatch = '/couple-activity/activity/coupleActivityOrder/deleteBatch',
	importExcel = '/couple-activity/activity/coupleActivityOrder/importExcel',
	exportXls = '/couple-activity/activity/coupleActivityOrder/exportXls',
	refundAAprtOfByUserId = '/couple-activity/activity/coupleActivityOrder/refundAAprtOfByUserId',
	coupleActivityOrderApplyInfoList = '/couple-activity/activity/coupleActivityOrder/listCoupleActivityOrderApplyInfoByMainId',
	coupleActivityOrderApplyInfoSave = '/couple-activity/activity/coupleActivityOrder/addCoupleActivityOrderApplyInfo',
	coupleActivityOrderApplyInfoEdit = '/couple-activity/activity/coupleActivityOrder/editCoupleActivityOrderApplyInfo',
	coupleActivityOrderApplyInfoDelete = '/couple-activity/activity/coupleActivityOrder/deleteCoupleActivityOrderApplyInfo',
	coupleActivityOrderApplyInfoDeleteBatch = '/couple-activity/activity/coupleActivityOrder/deleteBatchCoupleActivityOrderApplyInfo',

}
/**
 * 导出api
 * @param params
 */
export const getExportUrl = Api.exportXls;

/**
 * 导入api
 */
export const getImportUrl = Api.importExcel;


/**
 * 列表接口
 * @param params
 */
export const list = (params) =>
	defHttp.get({ url: Api.list, params });

/**
 * 删除单个
 */
export const deleteOne = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.deleteOne, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const batchDelete = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.deleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const saveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.edit : Api.save;
	return defHttp.post({ url: url, params });
}
/**
 * 退款
 */
export const refundAAprtOfByUserId = (params) => {
	return defHttp.post({ url: Api.refundAAprtOfByUserId, params });
}


/**
 * 列表接口
 * @param params
 */
export const coupleActivityOrderApplyInfoList = (params) => {
	if (params['orderId']) {
		return defHttp.get({ url: Api.coupleActivityOrderApplyInfoList, params });
	}
	return Promise.resolve({});
}


/**
 * 删除单个
 */
export const coupleActivityOrderApplyInfoDelete = (params, handleSuccess) => {
	return defHttp.delete({ url: Api.coupleActivityOrderApplyInfoDelete, params }, { joinParamsToUrl: true }).then(() => {
		handleSuccess();
	});
}
/**
 * 批量删除
 * @param params
 */
export const coupleActivityOrderApplyInfoDeleteBatch = (params, handleSuccess) => {
	createConfirm({
		iconType: 'warning',
		title: '确认删除',
		content: '是否删除选中数据',
		okText: '确认',
		cancelText: '取消',
		onOk: () => {
			return defHttp.delete({ url: Api.coupleActivityOrderApplyInfoDeleteBatch, data: params }, { joinParamsToUrl: true }).then(() => {
				handleSuccess();
			});
		}
	});
}
/**
 * 保存或者更新
 * @param params
 */
export const coupleActivityOrderApplyInfoSaveOrUpdate = (params, isUpdate) => {
	let url = isUpdate ? Api.coupleActivityOrderApplyInfoEdit : Api.coupleActivityOrderApplyInfoSave;
	return defHttp.post({ url: url, params });
}
/**
 * 导入
 */
export const coupleActivityOrderApplyInfoImportUrl = '/activity/coupleActivityOrder/importCoupleActivityOrderApplyInfo'

/**
 * 导出
 */
export const coupleActivityOrderApplyInfoExportXlsUrl = '/activity/coupleActivityOrder/exportCoupleActivityOrderApplyInfo'